package com.feng.controller.front;

import com.feng.dto.ProductDto;
import com.feng.service.ProductService;
import com.feng.vo.FrontPageVo;
import com.feng.vo.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: 丰
 * @date: 2022/12/30 12:01
 */
@RestController
@RequestMapping("/front/product")
@Api(tags = "前台产品接口")
public class FrontProductController {

    @Autowired
    private ProductService productService;

    @ApiOperation("根据id查询")
    @GetMapping("/findById/{id}")
    public ResultVo<List<ProductDto>> findById(@PathVariable("id") Integer id){
        return productService.findByIdFront(id);
    }

    @ApiOperation("根据分类查询")
    @GetMapping("/getAll")
    public ResultVo<List<ProductDto>> getAll(FrontPageVo frontPageVo){
        return productService.getAll(frontPageVo);
    }
}
